package com.youmu.shop.login.interceptor;

import javax.security.auth.login.LoginException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.youmu.shop.context.utils.UserContext;
import com.youmu.shop.system.vo.UserInfo;

/**
 * 
 * <p>Title:LoginInterceptor</p>
 * @author xc
 * @version	v1.0
 * <p>Date:2016年11月24日上午10:04:17</p>
 * <p>Description:TODO</p>
 */
public class LoginInterceptor implements HandlerInterceptor{
	public static final Logger logger = LoggerFactory.getLogger(LoginInterceptor.class);
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		UserInfo userInfo = UserContext.getUserInfo();
		if(userInfo == null){
			request.getRequestDispatcher("/dispatching/no-permission.html").forward(request, response);
		}
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		
	}

	
	

	
}
